use "$clean/clean_all.dta", clear





loc experiments " canvass_any_main_unres  " 
		   
		   
preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in  1 2 {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""

foreach choice in `experiments' {

/* Statistics */

logit `choice' treatment , vce(r)
	estadd loc thisstat7 = `e(N)': col`colnum'
    sigstar treatment, prec(3)
    estadd loc thisstat2 = "`r(bstar)'": col`colnum'
    estadd loc thisstat3 = "`r(sestar)'": col`colnum'
	

	margins , dydx(treatmen)
	local temp = el(r(b),1,1)
	estadd scalar thisstat5 = `temp': col`colnum'
	
	qui sum `choice'  if treatment==0
    estadd scalar thisstat6 = r(mean): col`colnum'

	estadd local thisstat8 = "No": col`colnum'
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"

	
logit `choice' treatment $contr , vce(r)
	estadd loc thisstat7 = `e(N)': col`colnum'
    sigstar treatment, prec(3)
    estadd loc thisstat2 = "`r(bstar)'": col`colnum'
    estadd loc thisstat3 = "`r(sestar)'": col`colnum'

	
	margins , dydx(treatmen)
	local temp = el(r(b),1,1)
	estadd scalar thisstat5 = `temp': col`colnum'
	
	qui sum `choice'  if  treatment==0
    estadd scalar thisstat6 = r(mean): col`colnum'

	estadd local thisstat8 = "Yes": col`colnum'
	
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	}



	

loc rowlabels " "   "Treatment" " " " " " \midrule  Marginal effect at mean" "\midrule Control mean" "Observations" "\hline Controls"

loc rowstats ""

forval i = 1/8 {
    loc rowstats "`rowstats' thisstat`i'"
}


esttab * using "$tables/Table_A6.tex", replace cells(none) booktabs nonotes compress alignment(c) ///
 nogap noobs nobaselevels label stats(`rowstats', labels("`rowlabels'") ///
 fmt( 3 3 3 3 3 3 3 0 0 0 0 0 0 3 3 3 3 3 3 3 0  3 3 3 3 3 3 3 3 3 3 3 3 0 ))  mlabels(none) ///
   mgroups( "Any canvassing" ,  pattern(1 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
